package com.czh.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czh.domain.ResponseResult;
import com.czh.domain.vo.MessageVo;
import com.czh.enums.AppHttpCodeEnum;
import com.czh.mapper.MessageMapper;
import com.czh.domain.entity.Message;
import com.czh.service.CommentService;
import com.czh.service.MessageService;
import com.czh.utils.BeanCopyUtils;
import com.czh.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Message)表服务实现类
 *
 * @author makejava
 * @since 2024-05-09 19:31:00
 */
@Service("messageService")
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {

    @Override
    public ResponseResult<Object> sendMessage(Message message) {
        if (message.getContent() == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.MESSAGE_ERROR);
        }else {
            save(message);
            return ResponseResult.okResult();
        }
    }

    @Override
    public ResponseResult<List<MessageVo>> getMessageList() {
       return ResponseResult.okResult(getBaseMapper().getAllByContent());
    }
}

